{% extends "admin/base.html" %}

{% block content %}
	<div class="jumbotron">
		<div class="container">
            <h1><b>{{ 'Notifications' if en else '通知' }}</b></h1>
		</div>
	</div>
	<div class="container">
		<div class="row">
			<div class="col-md-12">
				{% with form = Forms.notifications.NotificationForm() %}
				<form method="POST" id="notifications_form" autocomplete="off">
					<div class="form-group">
						<b>{{ 'Title' if en else form.title.label }}</b>
						{{ form.title(class="form-control") }}
						<small class="form-text text-muted">
                            {{ 'Notification title' if en else form.title.description }}
						</small>
					</div>
					<div class="form-group">
						<b>{{ 'Content' if en else form.content.label }}</b>
						{{ form.content(class="form-control", rows="3") }}
						<small class="form-text text-muted">
                            {{ 'Notification contents. Can consist of HTML and/or Markdown.' if en else form.content.description }}
						</small>
					</div>
					<div class="form-row">
						<div class="col">
							<div class="form-group">
								<b>{{ 'Notification Type' if en else form.type.label }}</b>
							</div>
							{% for radio in form.type %}
								<div class="form-check form-check-inline pr-1">
									{{ radio(class="form-check-input") }}
									{{ radio.label(class="form-check-label") }}
								</div>
							{% endfor %}
							<small class="form-text text-muted">
                                {{ 'What type of notification users receive' if en else form.type.description }}
							</small>
						</div>
						<div class="col">
							<div class="form-group">
								<b>{{ 'Play Sound' if en else form.sound.label }}</b>
							</div>
							<div class="form-check">
								{{ form.sound(class="form-check-input") }}
								{{ form.sound.label(class="form-check-label") }}
							</div>
							<small class="form-text text-muted">
								{{ form.sound.description }}
							</small>
						</div>
					</div>
					<div class="float-right">
                        {% if en %}
                        {{ form.submit(class="btn btn-success text-center",value="Submit") }}
                        {% else %}
                        {{ form.submit(class="btn btn-success text-center",value="提交") }}
                        {% endif %}
					</div>
				</form>
				{% endwith %}
			</div>
		</div>
	</div>

	<div class="container">
		<div class="row">
			<div class="col-md-12">
				<hr>
				<div id="notifications-list">
				{% for notification in notifications %}
					<div class="card bg-light mb-4">
						<button type="button" data-notif-id="{{ notification.id }}" class="delete-notification close position-absolute p-3" style="right:0;" data-dismiss="alert" aria-label="Close">
							<span aria-hidden="true">&times;</span>
						</button>
						<div class="card-body">
							<h3 class="card-title">{{ notification.title }}</h3>
							<blockquote class="blockquote mb-0">
								<p>{{ notification.html }}</p>
								<small class="text-muted"><span data-time="{{ notification.date | isoformat }}"></span></small>
							</blockquote>
						</div>
					</div>
				{% endfor %}
				</div>
			</div>
		</div>
	</div>
{% endblock %}

{% block scripts %}
{% endblock %}

{% block entrypoint %}
	<script defer src="{{ url_for('views.themes', theme='admin', path='js/pages/notifications.js') }}"></script>
{% endblock %}
